# patent_spider 实现对专利号网站查询与登录
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
import time
from get_chrome import get_chrombrowser

chrome_browser = get_chrombrowser()

login_url= r'https://tysf.cponline.cnipa.gov.cn/am/#/user/login'
chrome_browser.get(login_url)

# 登录网站
# proxy.new_har('patent', options={
#     'captureHeaders': True, 'captureContent': True})
# login_url= r'https://cpquery.cponline.cnipa.gov.cn/chinesepatent/index'
# chrome_browser.get(login_url)
# time.sleep(3)
#
# # 选择代理机构
# chrome_browser.find_element_by_xpath('//span[text()="代理机构登录"]').click()
# time.sleep(2)
#
# # 输入账号密码登录
# user=r'42264'
# passwd=r'Xhhg2019@'
# el_user = chrome_browser.find_element_by_xpath('//input[@placeholder="代理机构代码"]')
# el_user.clear()
# time.sleep(1)
# el_user.send_keys(user)
# time.sleep(1)
# el_passwd = chrome_browser.find_element_by_xpath('//input[@placeholder="请输入密码"]')
# el_passwd.clear()
# time.sleep(1)
# el_passwd.send_keys(passwd)
# time.sleep(1)
# chrome_browser.find_element_by_xpath('//span[text()="登录"]').click()
# time.sleep(5)
# input('@@滑动验证码登录：@@')
#
# # 拦截登录用户信息获取Authorization信息
# while status:
#             t_url = r'https://cpquery.cponline.cnipa.gov.cn/connect/user'
#             res = proxy.har
#             data = res.get('log').get('entries')
#             for item in data:
#                 url = item.get('request').get('url')
#                 if t_url in url:
#                     header = item.get('request').get('headers')
#                     for h_item in header:
#                         if h_item.get('name') == 'Authorization':
#                             Authorization = h_item['value']
#                             if Authorization:
#                                 status = False
#                                 print('@@获取Authorization成功,Authorization:%s@@' % Authorization)
#                                 server.stop()
#             time.sleep(5)
# chrome_browser.quit()









